import {defineStore} from "pinia"
import {ref} from "vue";
// @ts-ignore
import type {Top} from "@/types/xiaoPeng"

export const useCiaoPenPageStore = defineStore("xiaoPeng", () => {
    const _topBarState = [
        {
            id: 1,
            imageUrl: "https://xps01.xiaopeng.com/cms/material/pic/2024/08-27/pic_20240827173407_30962.jpg",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 2,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 3,
            imageUrl: "https://img1.baidu.com/it/u=491915170,2341497418&fm=253&fmt=auto&app=120&f=JPEG?w=667&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 4,
            imageUrl: "https://img1.baidu.com/it/u=1654271637,992661572&fm=253&fmt=auto&app=120&f=JPEG?w=1295&h=800",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 5,
            imageUrl: "https://img0.baidu.com/it/u=937809887,2657272018&fm=253&fmt=auto&app=120&f=JPEG?w=570&h=341",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 6,
            imageUrl: "https://img1.baidu.com/it/u=2978889656,1037105040&fm=253&fmt=auto&app=120&f=JPEG?w=569&h=329",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 7,
            imageUrl: "https://objectmc2.oss-cn-shenzhen.aliyuncs.com/yhdoc/202401/04/202401041022181826366661.jpeg",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 8,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 9,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 10,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 11,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 12,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 13,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 14,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 15,
            imageUrl: "https://img1.baidu.com/it/u=1804178100,3398465494&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 16,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 17,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 18,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 19,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 20,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 21,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 22,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
        {
            id: 23,
            imageUrl: "https://n.sinaimg.cn/spider20240219/246/w1640h1006/20240219/4cb7-4740a25ccd11e150599ecb94bca481ea.png",
            price: "￥119,800起",
            description: "M03 智能纯电 掀背轿"
        },
    ]
    const topBarState = ref<Top[]>([])

    const getTopBarState = (page: number, size: number = 3) => {
        return new Promise<{
            // data: topBarState[];
            page: number;
            total: number;
            hasMore: boolean;
        }>((resolve => {
            setTimeout(() => {
                const data = _topBarState.slice((page - 1) * size, page * size)
                // @ts-ignore
                topBarState.value = [...topBarState.value, ...data];
                resolve({
                    // data,
                    page,
                    total: _topBarState.length,
                    hasMore: page * size < _topBarState.length
                });
            }, 500);
        }))
    }
    return {
        topBarState,
        getTopBarState,
        _topBarState
    }
})
